﻿#include <iostream>
#include <cstdlib>
#include <ctime>
#include <list>
#include <vector>
#include <algorithm>
#include <unistd.h>

using namespace std;

void test1()
{
    list<char> buf;
    for(int i = 0; i < 20; i++)
    {
        buf.push_back(rand()%26+97);
    }
    buf.sort();
    buf.unique();

    for(list<char>::iterator it = buf.begin(); it != buf.end(); it++)
    {
        cout << *it;
    }
    cout << endl;

}

void test2()
{
//    cout << __LINE__ << endl;
    list<int> mylist;
    for(int i = 0; i < 5; i++)
    {
        mylist.push_back(rand()%100);
    }

    list<int> seclist;

    cout << "size()" <<  mylist.size() << endl;

    mylist.remove_if([&](int i)
    {
        sleep(1);
        cout << i << endl;
        if(i%2 == 0)//偶数
        {
            mylist.push_back(i);
            return true;
        }
        return false;
    });

//    mylist.sort([](int &a, int &b){cout << "::::::" << a << b << endl; return false;});

    cout << endl;
}

int main()
{
    srand(time(nullptr));
    test2();
    return 0;
}
